#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
constexpr int inf = 0x3f3f3f3f;
constexpr ll infll = 0x3f3f3f3f3f3f3f3f;
constexpr double EPS = 1e-8;
constexpr double PI = atan(1) * 4;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> inline bool chmax(T& x, T y) {return x < y ? x = y, 1 : 0;}
template <typename T> inline bool chmin(T& x, T y) {return x > y ? x = y, 1 : 0;}
inline int LSB(int i) {return (i & -i);}
/*
- Read carefully
- Look for patterns/observations
- Think backwards
*/
constexpr int maxn = 2e5+5;
int n, cnt[maxn][30], curmask[maxn], sign[maxn];
ll res = 0;
unordered_map <int, int> masks[2][27];
string s[maxn];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++){
cin >> s[i];
sign[i] = ((int)s[i].length()) % 2;
for (char c : s[i]){
curmask[i] ^= (1 << (c - 'a'));
cnt[i][c - 'a']++;
}
for (int j = 0; j < 26; j++){
if (!cnt[i][j]) masks[sign[i]][j][curmask[i]]++;
}
}
for (int i = 1; i <= n; i++){
// Try all letters it doesn't have
for (int j = 0; j < 26; j++){
if (!cnt[i][j]){
res += masks[sign[i] ^ 1][j][((1 << 26) - 1) ^ curmask[i] ^ (1 << j)];
}
}
}
cout << res / 2 << endl;
return 0;
}
1323. Maximum 69 Number | 832. Flipping an Image |
1295. Find Numbers with Even Number of Digits | 1704. Determine if String Halves Are Alike |
1732. Find the Highest Altitude | 709. To Lower Case |
1688. Count of Matches in Tournament | 1684. Count the Number of Consistent Strings |
1588. Sum of All Odd Length Subarrays | 1662. Check If Two String Arrays are Equivalent |
1832. Check if the Sentence Is Pangram | 1678. Goal Parser Interpretation |
1389. Create Target Array in the Given Order | 1313. Decompress Run-Length Encoded List |
1281. Subtract the Product and Sum of Digits of an Integer | 1342. Number of Steps to Reduce a Number to Zero |
1528. Shuffle String | 1365. How Many Numbers Are Smaller Than the Current Number |
771. Jewels and Stones | 1512. Number of Good Pairs |
672. Richest Customer Wealth | 1470. Shuffle the Array |
1431. Kids With the Greatest Number of Candies | 1480. Running Sum of 1d Array |
682. Baseball Game | 496. Next Greater Element I |
232. Implement Queue using Stacks | 844. Backspace String Compare |
20. Valid Parentheses | 746. Min Cost Climbing Stairs |